(require 'geiser-guile)
(require 'geiser-chez)
(require 'geiser-chicken)
(require 'geiser-gambit)
(require 'geiser-gauche)
(require 'geiser-racket)

;; Highlight matching pairs of parentheses.
(setq show-paren-delay 0)
(show-paren-mode)

(defun scheme-init-hook ()
  (enable-paredit-mode)
  (rainbow-delimiters-mode))

(defun paredit-scheme-init-hook ()
  (require 'paredit)
  (enable-paredit-mode)
  (rainbow-delimiters-mode))

(defun rainbow-delimiters-scheme-init-hook ()
  (require 'rainbow-delimiters)
  (add-hook 'geiser-repl-mode-hook 'rainbow-delimiters-mode))

;; scheme-mode settings
(add-hook 'scheme-mode-hook 'scheme-init-hook)
(add-to-list 'auto-mode-alist '("\\.chz\\'" . scheme-mode))
(add-to-list 'auto-mode-alist '("\\.chez-geiser\\'" . scheme-mode))
(add-to-list 'auto-mode-alist '("\\.guile-geiser\\'" . scheme-mode))

;; geiser settings
(setq geiser-repl-skip-version-check-p 't)
(setq geiser-active-implementations '(guile chez chicken gambit gauche racket))
(setq geiser-implementations-alist '(((regexp "\\.scm$") guile)
				     ((regexp "\\.ss$") racket)
				     ((regexp "\\.rkt$") racket)
				     ((regexp "\\.chz$") chez)))

(add-to-list 'geiser-guile-load-path "~/source/scheme/guile")

;; (add-to-list 'geiser-implementations-alist
;;                 '((regexp "\\.chz$") chez))

;; (eval-after-load "geiser-impl"
;;   '(add-to-list 'geiser-implementations-alist
;;                 '((regexp "\\.chz$") chez)))

;; chez settings
(setq geiser-chez-binary "petite")

;; guile settings
(setq geiser-guile-load-init-file-p nil)

(add-hook 'scheme-mode-hook 'paredit-scheme-init-hook)
(add-hook 'scheme-mode-hook 'rainbow-delimiters-scheme-init-hook)

(add-hook 'geiser-repl-mode-hook 'paredit-scheme-init-hook)
(add-hook 'geiser-repl-mode-hook 'rainbow-delimiters-scheme-init-hook)
